﻿<%@ WebHandler Language="C#" Class="DeleteHandler" %>

using System;
using System.Web;
using System.Data;
using Cache.Redis;
using Model.Port;
using Model.Voyage;
using Model.User;
using Model.GameEvent;

public class DeleteHandler : IHttpHandler
{
    private HttpContext context;
    public void ProcessRequest(HttpContext context)
    {
        this.context = context;
        context.Response.ContentType = "text/plain";
        string result = string.Empty;
        string method = context.Request["method"];
        switch (method)
        {
            case "DeleteAll":
                result = DeleteAll();
                break;
            default: break;
        }
        context.Response.Write(result);
    }

    /// <summary>
    /// 清空所有数据
    /// </summary>
    /// <returns></returns>
    public string DeleteAll()
    {
        string sqlStr = @"delete from account";
        MySQLDataControl.ExecuteNonQuery(MySQLDataControl.GetConnection(), CommandType.Text, sqlStr);

        sqlStr = @"delete from loginlog";
        MySQLDataControl.ExecuteNonQuery(MySQLDataControl.GetConnection(), CommandType.Text, sqlStr);

        //RedisHelper.instance.Remove(CaptainData.DB_Name);
        //RedisHelper.instance.Remove(CaptainFullNameData.DB_Name);
        //RedisHelper.instance.Remove(RoleData.DB_Name);
        //RedisHelper.instance.Remove(SeaConnectData.DB_Name);
        //RedisHelper.instance.Remove(SeaMaskData.DB_Name);
        //RedisHelper.instance.Remove(SeaPointData.DB_Name);
        //RedisHelper.instance.Remove(ShipData.DB_Name);
        //RedisHelper.instance.Remove(ShipTrainData.DB_Name);
        //RedisHelper.instance.Remove(LoginLogData.login_token);
        //RedisHelper.instance.Remove(VoyageData.DB_Name);
        RedisHelper.instance.Remove(SeaCommodityData.DB_Name);
        //RedisHelper.instance.Remove(BuildingData.DB_Name);
        //RedisHelper.instance.Remove(BuildingWorkTaskData.DB_Name);
        //RedisHelper.instance.Remove(CollectPointData.DB_Name);
        //RedisHelper.instance.Remove(LockZoneData.DB_Name);
        //RedisHelper.instance.Remove(RoadData.DB_Name);
        //RedisHelper.instance.Remove(RoadPointData.DB_Name);

        return "true";
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}